<!DOCTYPE html>
<html>
<head>
  <title>No.6</title>
  <style>
    html,body {
      margin: 0 auto;
      height: 100%;
      width: 100%;
    }
    .container {
      position: relative;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background-size: 100% 100%;
    }
    .images {
      z-index: 3;
      width: 800px;
      height: 100px;
      position: absolute;
      display: flex;
      bottom: 50px;
      left: 50%;
      margin-left: -400px;
      justify-content: space-between;
      align-items: center;
    }
    .images > div {
      width: 130px;
      height: 90px;
      flex: none;
      background-size: 100% 100%;
    }
    .img1 {
      background-image: url(images/1.jpg);
    }
    .img2 {
      background-image: url(images/2.jpg);
    }
    .img3 {
      background-image: url(images/3.jpg);
    }
    .img4 {
      background-image: url(images/4.jpg);
    }
    .img5 {
      background-image: url(images/5.jpg);
    }
    img {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
    .images > div > span {
      display: block;
      width: 100%;
      height: 100%;
      background-color: black;
      opacity: 0.5;
      cursor: pointer;
    }
    .images > div > span:hover {
      opacity: 0;
    }
    .container > img:nth-of-type(1) {
      z-index: 2;
      display: block;
    }
    .container > img:nth-of-type(2) {
      display: block;
    }
    .container > img:nth-of-type(3) {
      display: block;
    }
    .container > img:nth-of-type(4) {
      display: block;
    }
    .container > img:nth-of-type(5) {
      display: block;
    }
    @keyframes imgmove1 {
      from{left: -500px;}
      to{left: 0px;}
    }
    @keyframes imgmove2 {
      from{top: 350px;}
      to{top: 0px;}
    }
    @keyframes imgmove3 {
      from{
        -webkit-transform: scale(0.1);
        -moz-transform: scale(0.1);
        -o-transform: scale(0.1);
        transform: scale(0.1);
      }
      to{
        -webkit-transform: scale(1);
        -moz-transform: scale(1);
        -o-transform: scale(1);
        transform: scale(1);
      }
    }
    @keyframes imgmove4 {
      from{
        -webkit-transform: scale(2);
        -moz-transform: scale(2);
        -o-transform: scale(2);
        transform: scale(2);
      }
      to{
        -webkit-transform: scale(1);
        -moz-transform: scale(1);
        -o-transform: scale(1);
        transform: scale(1);
      }
    }
    @keyframes imgmove5 {
      from{
        -webkit-transform: rotate(-360deg) scale(0.1);
        -moz-transform: rotate(-360deg) scale(0.1);
        -o-transform: rotate(-360deg) scale(0.1);
        transform: rotate(-360deg) scale(0.1);
      }
      to{
        -webkit-transform: rotate(0) scale(1);
        -moz-transform: rotate(0) scale(1);
        -o-transform: rotate(0) scale(1);
        transform: rotate(0) scale(1);
      }
    }
    .img1Animation {
      -webkit-animation: imgmove1 0.5s ease-out;
              animation: imgmove1 0.5s ease-out;
    }
    .img2Animation {
      -webkit-animation: imgmove2 0.5s ease-out;
              animation: imgmove2 0.5s ease-out;
    }
    .img3Animation {
      -webkit-animation: imgmove3 1s ease-in;
              animation: imgmove3 0.5s ease-out;
    }
    .img4Animation {
      -webkit-animation: imgmove4 1s ease-out;
              animation: imgmove4 0.5s ease-out;
    }
    .img5Animation {
      -webkit-animation: imgmove5 0.7s ease-in-out;
              animation: imgmove5 0.5s ease-out;
    }
  </style>
</head>
<body>
<div class="container">
  <img src="images/1.jpg">
  <img src="images/2.jpg">
  <img src="images/3.jpg">
  <img src="images/4.jpg">
  <img src="images/5.jpg">
    <div class="images">
      <div class="img1"><span></span></div>
      <div class="img2"><span></span></div>
      <div class="img3"><span></span></div>
      <div class="img4"><span></span></div>
      <div class="img5"><span></span></div>
    </div>
</div>
<script>
var imagesDiv = document.getElementsByClassName("images")[0];
var imgs = document.getElementsByTagName("img");
var container = document.getElementsByClassName("container")[0];
var index = 0;
var lastIndex = 0;          //记录点击图片时上一张图片的下标
imagesDiv.onclick = function(event){
  var event = event || window.event;
  if(event.target.nodeName.toLowerCase() == "span"){
    for(var i=0;i<imgs.length;i++){
      imgs[i].style.display = "none";
      imgs[i].className = "";
    }
    index = Number(event.target.parentNode.className.substr(-1,1)) - 1;
    imgs[index].style.display = "block";
    imgs[index].className = "img" + (index+1) + "Animation";
    container.style.backgroundImage = "url(images/" + (lastIndex+1) + ".jpg)";
    lastIndex = index;
  }
}
</script>
</body>
</html>